package project_package;

import java.util.Calendar;

public class Rent
{
	int id;
	String name;
	long leaseDate;
	long leasePeriod;
	long leaseReturned;
	Customer customer;
	double price;
	boolean isLeased;
	Employee employee;
	
	public Rent(int id, String name, long leaseDate, long leasePeriod, long leaseReturned, Customer customer, double price, boolean isLeased, Employee employee)
	{
		this.id = id;
		this.name = name;
		this.leaseDate = leaseDate; 
		this.leasePeriod = leasePeriod;
		this.leaseReturned = leaseReturned;
		this.customer = customer;
		this.price = price;
		this.isLeased = isLeased;
		this.employee = employee;
	}
	
	// gets rent id
	public int getID() 
	{
		return id;
	}
	
	// gets rent name
	public String getName() 
	{
		return name;
	}
	
	// gets rent lease date (unix timestamp)
	public long getLeaseDate()
	{
		return leaseDate;
	}
	
	// gets rent lease period (in days)
	public long getLeasePeriod()
	{
		return leasePeriod;
	}
	
	// gets rent return date (unix timestamp)
	public long getLeaseReturned()
	{
		return leaseReturned;
	}
	
	// gets rent day which should be returned
	public long getLeaseReturnDate()
	{
		long returnDate = leaseDate + (leasePeriod*86400);
		return returnDate;
	}
	
	// gets rent lease date in d.m.Y h:i format
	public String getLeaseDateString()
	{
		return getDateToString(leaseDate);
	}
		
	// gets rent lease returned date in d.m.Y h:i format
	public String getLeaseReturnedString() 
	{
		return getDateToString(leaseReturned);
	}
		
	// gets rent lease return date in d.m.Y h:i format
	public String getLeaseReturnDateString() 
	{
		return getDateToString(getLeaseReturnDate());
	}
	
	// method to help us save time on unix timestamp to d.m.Y h:i format
	public String getDateToString(long date) 
	{
		// method to transform unix timestamp to normal date
		// example: 1355531526 will return 15.12.2012 01:32
		Calendar calLeaseDate = Calendar.getInstance();
		calLeaseDate.setTimeInMillis(date*1000);
		String dateString = calLeaseDate.get(Calendar.DAY_OF_MONTH)+"."+calLeaseDate.get(Calendar.MONTH)+"."+calLeaseDate.get(Calendar.YEAR)+" "+calLeaseDate.get(Calendar.HOUR_OF_DAY)+":"+calLeaseDate.get(Calendar.MINUTE);
		return dateString;
	}
	
	// gets customer
	public Customer getCustomer()
	{
		return customer;
	}
	
	// gets price
	public double getPrice() 
	{
		return price;
	}
	
	// gets if available or not
	public boolean getIsLeased() 
	{
		return isLeased;
	}
	
	// gets employee
	public Employee getEmployee()
	{
		return employee;
	}
	
	// sets id
	public void setID(int id) 
	{
		this.id = id;
	}
	
	// sets name
	public void setName(String name) 
	{
		this.name = name;
	}
	
	// sets lease date (unix timestamp)
	public void setLeaseDate(long leaseDate) 
	{
		this.leaseDate = leaseDate;
	}
	
	// sets lease period (in days)
	public void setLeasePeriod(long leasePeriod)
	{
		this.leasePeriod = leasePeriod;
	}
	
	// sets lease returned (unix timestamp)
	public void setLeaseReturned(long leaseReturned) 
	{
		this.leaseReturned = leaseReturned;
	}
	
	// sets customer
	public void setCustomer(Customer customer)
	{
		this.customer = customer;
	}		
	
	// sets price
	public void setPrice(double price)
	{
		this.price = price;
	}
	
	// sets if available or not
	public void setIsLeased(boolean isLeased)
	{
		this.isLeased = isLeased;
	}
	
	// sets employee
	public void setEmployee(Employee employee) 
	{
		this.employee = employee;
	}
}